#include <gogo.h>

#define B2C printf("%c",0xFA);delay_us(10);printf("%c",0x54);delay_us(10);



void init(){
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   setup_adc_ports( ALL_ANALOG );
   setup_adc(ADC_CLOCK_INTERNAL );
}

void getFirstByte(int value){
   printf("%c",(value >> 8) & 0x03);
}

void getSecondByte(int value){
   printf("%c",value & 0xff);
}

void main(){
   int16 value = 0;
   int8 i = 0;
   int8 valueByte = 0;
   int8 tempValue = 0;
   init();
   
   while(1){
      valueByte = 0;
      tempValue = 0;
      for(i = 0;i<8;i++){
         set_adc_channel(i);
         delay_us(50);
         value = read_adc();
         
         //sent
         B2C
         printf("%c",i);
         printf("%c",(value >> 8));
         printf("%c",value & 0xff);
         //getFirstByte(value);
         //getSecondByte(value);
      } 
   }
}

